//
//  RealTableViewCell.m
//  Streaming
//
//  Created by 官琛 on 15-6-27.
//  Copyright (c) 2015年 liuxun. All rights reserved.
//

#import "RealTableViewCell.h"

@implementation RealTableViewCell
- (void)dealloc
{
    [self.image release];
    [self.title release];
    [self.title2 release];
    [self.commentCount release];
    [self.real release];
    
    [super dealloc];
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        if (WIDTH == 320 && HEIGHT == 568) {
            [self creatTable5];
        }
        if (WIDTH == 414 && HEIGHT == 736) {
            [self creatTablePlus];
        }
        if (WIDTH == 375 && HEIGHT == 667){
            [self creatTable6];
        }

    }
    return self;
}
-(void)creatTable5
{
    self.image = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 100, 100)];
    self.image.layer.shadowColor = [UIColor blackColor].CGColor;
    self.image.layer.shadowOffset = CGSizeMake(0, 10);
    self.image.layer.shadowOpacity = 0.5;
    self.image.layer.shadowRadius = 10.0;
    [self.contentView addSubview:self.image];
    [_image autorelease];
    
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(self.image.frame.origin.x+self.image.frame.size.width+15, self.image.frame.origin.y , 190, 30)];
    [self.title setBackgroundColor:[UIColor clearColor]];
    self.title.font = [UIFont boldSystemFontOfSize:16];
    [self.contentView addSubview:self.title];
    [_title autorelease];
    
    self.title2 = [[UILabel alloc]initWithFrame:CGRectMake(self.image.frame.origin.x+self.image.frame.size.width+15, self.title.frame.origin.y+self.title.frame.size.height, 190, 40)];
    self.title2.numberOfLines = 0;
    self.title2.font = [UIFont systemFontOfSize:14];
    [self.title2 setBackgroundColor:[UIColor clearColor]];
    self.title2.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.title2];
    [_title autorelease];
    
    self.commentCount = [[UILabel alloc]initWithFrame:CGRectMake(self.title2.frame.origin.x, self.title2.frame.origin.y+self.title2.frame.size.height, 50, 20)];
    self.commentCount.font = [UIFont systemFontOfSize:14];
    self.commentCount.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.commentCount];
    [_commentCount autorelease];
}

-(void)creatTable6
{
    self.image = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 100, 100)];
    self.image.layer.shadowColor = [UIColor blackColor].CGColor;
    self.image.layer.shadowOffset = CGSizeMake(0, 10);
    self.image.layer.shadowOpacity = 0.5;
    self.image.layer.shadowRadius = 10.0;
    [self.contentView addSubview:self.image];
    [_image autorelease];
    
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(self.image.frame.origin.x+self.image.frame.size.width+20, self.image.frame.origin.y, 250, 30)];
    self.title.font = [UIFont boldSystemFontOfSize:18];
    [self.contentView addSubview:self.title];
    [_title autorelease];
    
    self.title2 = [[UILabel alloc]initWithFrame:CGRectMake(self.image.frame.origin.x+self.image.frame.size.width+10, self.title.frame.origin.y+40, 250, 20)];
    self.title2.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.title2];
    [_title autorelease];
    
    self.commentCount = [[UILabel alloc]initWithFrame:CGRectMake(self.title2.frame.origin.x, self.title2.frame.origin.y+30, 50, 20)];
    self.commentCount.font = [UIFont systemFontOfSize:14];
    self.commentCount.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.commentCount];
    [_commentCount autorelease];
}

-(void)creatTablePlus
{
    self.image = [[UIImageView alloc]initWithFrame:CGRectMake(10, 15, 100, 100)];
    self.image.layer.shadowColor = [UIColor blackColor].CGColor;
    self.image.layer.shadowOffset = CGSizeMake(0, 10);
    self.image.layer.shadowOpacity = 0.5;
    self.image.layer.shadowRadius = 10.0;
    [self.contentView addSubview:self.image];
    [_image autorelease];
    
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(self.image.frame.origin.x+self.image.frame.size.width+25, self.image.frame.origin.y, 280, 30)];
    self.title.font = [UIFont boldSystemFontOfSize:19];
    [self.contentView addSubview:self.title];
    [_title autorelease];
    
    self.title2 = [[UILabel alloc]initWithFrame:CGRectMake(self.image.frame.origin.x+self.image.frame.size.width+15, self.title.frame.origin.y+40, 280, 20)];
    self.title2.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.title2];
    [_title autorelease];
    
    self.commentCount = [[UILabel alloc]initWithFrame:CGRectMake(self.title2.frame.origin.x, self.title2.frame.origin.y+35, 100, 20)];
    self.commentCount.font = [UIFont systemFontOfSize:15];
    self.commentCount.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.commentCount];
    [_commentCount autorelease];
}




-(void)setReal:(Real *)real
{
    if (_real != real) {
        [_real release];
        _real = [real retain];
    }
    NSURL *url = [NSURL URLWithString:real.image];
    [self.image sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"111111.png"]];
    self.title.text = real.title;
    self.title2.text = real.title2;
    NSString *str = [NSString stringWithFormat:@"%ld",real.commentCount];
    self.commentCount.text = [NSString stringWithFormat:@"评论:%@",str];
    

}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
